package com.yanqu.road.server.cmd.orewar;

import com.yanqu.road.entity.player.UserBaseInfo;
import com.yanqu.road.logic.pb.PlayerBasePb;
import com.yanqu.road.server.cmd.CrossUnionCommand;
import com.yanqu.road.utils.YanQuMessageUtils;
import com.yanqu.road.pb.orewar.OreWarProto;
import com.yanqu.road.server.cmd.CrossCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.logic.MessageHelper;
import com.yanqu.road.server.manager.orewar.CrossOreWarMgr;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.Protocol;


@Cmd(code = Protocol.C_CROSS_OREWAR_RECALL, desc = "撤回跨服盐场坑位")
public class CrossRecallPitCmd extends CrossUnionCommand {

    private long userId;
    private int activityId;
    private int pitId;
    private UserBaseInfo userBaseInfo;

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        OreWarProto.CrossOrePitRecallReqMsg reqMsg = OreWarProto.CrossOrePitRecallReqMsg.parseFrom(packet.getBytes());
        userId = packet.getPlayerId();
        activityId = reqMsg.getActivityId();
        pitId = reqMsg.getPitId();
        userBaseInfo = PlayerBasePb.parseToUserBaseInfo(reqMsg.getPlayerBaseData());

        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {
        OreWarProto.CrossOrePitRecallRespMsg.Builder respMsg = CrossOreWarMgr.orePitRecall(activityId,userId,userBaseInfo,pitId,groupId);
        YanQuMessage pbMsg = YanQuMessageUtils.buildMessage(Protocol.S_CROSS_ORE_WAR_PIT_RECALL, respMsg);
        MessageHelper.sendPacket(serverId, userId, pbMsg);
    }

    @Override
    public void sendData() {

    }

}
